<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
	</head>
	<body>
		<div>过滤前内容：<br>
		<textarea id="pre" rows="10" cols="40"></textarea>
		<input id="btn" type="button" value="过滤">
		</div>
		<div>过滤后内容：<br>
		<textarea id="res" rows="10" cols="40"></textarea>
		</div>
		<script>
			//定义按钮的点击事件
			var btn=document.getElementById('btn');
			btn.onclick=function(){
				var str=document.getElementById('pre').value;
				var reg=/[\u4e00-\u9fa5]|(bad)/gi;
				var newStr=str.replace(reg,'*');
				document.getElementById('res').innerHTML=newStr;
			};
		</script>
	</body>
</html>
